package com.itheima.bos.web.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.itheima.bos.domain.system.Role;
import com.itheima.bos.service.system.IRoleSerivce;
import com.itheima.bos.web.action.common.BaseAction;

public class RoleAction extends BaseAction<Role> {

	// 注入业务层
	@Autowired
	private IRoleSerivce roleService;

	// 角色列表的显示功能
	@Action(value = "role_list", results = { @Result(name = "success", type = "json") })
	public String list() {

		// 调用业务层查询角色信息
		List<Role> roles = roleService.findAll();
		//压入值栈
		pushPageDataToValueStack(roles);

		return SUCCESS;
	}
	
	//获取权限id和菜单id
	private String[] permissionIds;
	private String menuIds;
	
	public void setPermissionIds(String[] permissionIds) {
		this.permissionIds = permissionIds;
	}

	public void setMenuIds(String menuIds) {
		this.menuIds = menuIds;
	}



	@Action(value="role_save",results={@Result(name="success",location="pages/system/role.html",type="redirect")})
	public String save(){
		
		roleService.save(model,permissionIds,menuIds);
		
		return SUCCESS;
	}
}
